package com.zero.yygh.msm.receiver;

import com.rabbitmq.client.Channel;
import com.zero.yygh.common.constant.MqConst;
import com.zero.yygh.msm.service.MsmService;
import com.zero.yygh.vo.msm.MsmVo;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author zero
 * @desc 短信接收监听
 * @create 2021/5/10
 */
@Component
public class MsmReceiver {

    @Resource
    private MsmService msmService;

    /**
     * 监听短信发送
     * @author zero
     * @date 2021/5/10 10:41
     * @param msmVo 短信模板内容
     * @param message 消息
     * @param channel 通道
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MqConst.QUEUE_MSM_ITEM, durable = "true"),
            exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_MSM),
            key = {MqConst.ROUTING_MSM_ITEM}
    ))
    public void send(MsmVo msmVo, Message message, Channel channel) {
        msmService.send(msmVo);
    }

}
